package com.daniel.design.principles.demo2.before;

/**
 * @ClassName Client
 * @Description 测试里氏代换原则
 * @Author Daniel
 * @Version V1.0.0
 */
public class Client {

    public static void resize(Rectangle rectangle) {
        while (rectangle.getWidth() <= rectangle.getLength()) {
            rectangle.setWidth(rectangle.getWidth() + 1);
        }
    }

    public static void printRectangle(Rectangle rectangle) {
        System.out.println("长为：" + rectangle.getLength());
        System.out.println("宽为：" + rectangle.getWidth());
    }

    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle();
        rectangle.setWidth(10);
        rectangle.setLength(20);
        resize(rectangle);
        printRectangle(rectangle);

        System.out.println("==============");
        Square square = new Square();
        square.setWidth(10);
        resize(square);
        printRectangle(square);
    }
}
